'''
Auther:CZero
Date:20201106
'''

import random

#随机生成20个正整数放到randomlist中
randomlist = []
for i in range(20):
    randomlist.append(random.randint(1,20))
print(randomlist)

#统计每个数字出现的次数
count = {}
for j in randomlist:
    if j in count:
        count[j] += 1
    else:
        count[j] = 1
print(count)

#排序并降序输出次数最多的前三个数字及次数
count2 = sorted(count.items(), key = lambda x:x[1],reverse=True)
print(count2[0:3])

# 完成的不错
